import Vue from 'vue'
import VueRouter from "vue-router"
import store from '../store/index'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: "/index"
    }, {
        path: '/index',
        name: '首页',
        component: () => import( /* webpackChunkName: "Index" */ '../views/Index.vue'),
        meta: {
            requiresAuth: true,
            title: '首页'
        },
    },
    {
        path: '/blog',
        name: '博客',
        component: () => import( /* webpackChunkName: "Blog" */ '../views/Blog.vue'),
        meta: {
            requiresAuth: true,
            title: '博客'
        },
    },
    {
        path: '/archives',
        name: '归档',
        component: () => import( /* webpackChunkName: "Archives" */ '../views/Archives.vue'),
        meta: {
            requiresAuth: true,
            title: '归档'
        },
    },
    {
        path: '/message',
        name: '留言板',
        component: () => import( /* webpackChunkName: "Message" */ '../views/Message.vue'),
        meta: {
            requiresAuth: true,
            title: '留言板'
        },
    },
    {
        path: '/link',
        name: '友链',
        component: () => import( /* webpackChunkName: "Link" */ '../views/Link.vue'),
        meta: {
            requiresAuth: true,
            title: '友链'
        },
    }

];

const router = new VueRouter({
    routes
})


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router;